package action;

import entity.tArea;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletResponse;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.apache.struts2.ServletActionContext;

import service.tAreaService;

public class SearchtAreaAllAtion {
	
	private String id;
	private String name;
	
	private tArea tarea;
	
	private tAreaService tareaService;
	
	public String search() throws IOException{
		
		ServletResponse response = ServletActionContext.getResponse();
		response.setCharacterEncoding("utf-8");
		PrintWriter out = response.getWriter();
		
		List<tArea> lists = new ArrayList<tArea>();
		
		JSONObject result = new JSONObject();
		
		lists = tareaService.searchAll();
		
			System.out.println(lists.get(0).getName());
		
		//System.out.println(lists.get(0).getName());
		
//		JSONArray jsonArray = new JSONArray();
//		
//		for(tArea tarea1 : lists){
//			JSONObject t = new JSONObject();
//			t.put(id, tarea1.getId());
//			t.put(name, tarea1.getName());
//			jsonArray.add(t);
//			
//			System.out.println(t);
//		}
		out.write(result.toString());
		out.flush();
		out.close();
		return null;
	}

	public tAreaService getTareaService() {
		return tareaService;
	}

	public void setTareaService(tAreaService tareaService) {
		this.tareaService = tareaService;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public tArea getTarea() {
		return tarea;
	}

	public void setTarea(tArea tarea) {
		this.tarea = tarea;
	}
	
	

}
